{% extends "admin/change_form.html" %}
{% load i18n adminmedia %}


{% block after_related_objects %}
{% if change %}
  <fieldset class="module aligned">
  <h2>{% trans "Menu Items" %}</h2>

  <div class="form-row" >
    <img src="{% admin_media_prefix %}img/admin/icon_addlink.gif" width="10" height="10"/> <a href="items/add/">{% trans "Add an item" %}</a>
  </div>

  <style type="text/css">
      .form-row tbody tr:hover{
          background-color: #ffffbe;
      }
  </style>

  <div class="form-row" >
    <table cellspacing="0" width="100%">
        <thead>
            <tr>
                <th>{% trans "Title" %}</th>
                <th>{% trans "Url" %}</th>
                <th colspan="2">{% trans "Move" %}</th>
            </tr>
        </thead>

        <tbody>
        {% for menu_item in original.root_item.get_flattened %}
            <tr class="{% cycle 'row1' 'row2' %}">

                {% if forloop.first %}
                    <td colspan="2">
                        {% trans "[Root]" %}
                    </td>
                {% else %}
                    <td width="45%">
                        <a href="items/{{ menu_item.pk }}/">{{ menu_item.title_with_spacer|safe }}</a>
                    </td>
                    <td width="35%">
                        {{ menu_item.adm_get_url }}
                    </td>
                {% endif %}

                {% if menu_item.has_siblings %}
                    {% ifnotequal menu_item.order menu_item.siblings.count %}
                        <td width="15" align="center"><a href="items/{{ menu_item.pk }}/move_down/"><img src="{% admin_media_prefix %}img/admin/arrow-down.gif" border="0" alt="{% trans 'Down' %}"/></b></td>
                    {% else %}
                        <td width="15">&nbsp;</td>
                    {% endifnotequal %}

                    {% ifnotequal menu_item.order 0 %}
                        <td width="15" align="center"><a href="items/{{ menu_item.pk }}/move_up/"><img src="{% admin_media_prefix %}img/admin/arrow-up.gif" border="0" alt="{% trans 'Up' %}"/></a></td>
                    {% else %}
                        <td width="15">&nbsp;</td>
                    {% endifnotequal %}
                {% else %}
                    <td width="15">&nbsp;</td><td width="15">&nbsp;</td>
                {% endif %}
            </tr>
        {% endfor %}
        </tbody>
    </table>
  </div>
  </fieldset>
{% endif %}
{% endblock %}
